<extend name='Index/index' />

<block name="main">
                <div class="bg-light lter b-b wrapper-md">
                    <h1 class="m-n font-thin h3">商品图片管理</h1>
                </div>
                <h4 style="margin-left:30px;"><a href="<{:U('Admin/Goodsimg/add?gid='.$gid)}>" class="btn btn-info">添加图片</a></h4>
                <div class="wrapper-md">
                    <div class="panel panel-default">
                        <div class="table-responsive">
                            <table class="table table-striped b-t b-light">
                                <thead>
                                    <tr>
                                        <th style="text-align:center;">ID</th>
                                        <th style="text-align:center;">商品ID</th>
                                        <th style="text-align:center;">商品图片</th>
                                        <th style="text-align:center;">封面</th>
                                        <th style="text-align:center;">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <volist name="goodsimglist" id="vo">
                                        <tr style="text-align:center;">
                                            <td class="myGiid"><{$vo.gi_id}></td>
                                            <td class="myGid"><{$vo.gi_g_id}></td>
                                            <td>
                                                <img src="/Uploads/Store/<{$vo.g_icon}>" width="100">
                                            </td>
                                            <if condition="$vo.face eq 0">
                                            <td class="myFace" style="cursor:pointer;">否</td>
                                            <else />
                                            <td class="myFace" style="cursor:pointer;">是</td>
                                            </if>
                                            <td><button class="btn btn-danger" data-toggle="modal">删除</button></td>
                                        </tr>
                                    </volist>
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <p></p>
                    <p></p>
                </div>
            <script>
                $('.myFace').click(function(){
                    var giid = $(this).prevAll('.myGiid').html();
                    var gid = $(this).prevAll('.myGid').html();
                    if($(this).html() == '否'){
                        $('.myFace').html('否');
                        $(this).html('是');
                        $.ajax({
                            type: 'post',
                            url: "<{:U('Admin/Goodsimg/editFace')}>",
                            data: 'giid='+giid+'&gid='+gid
                        });
                    }
                });

                $('.btn-danger').click(function(){
                    $(this).parents('tr').remove();
                    var giid = $(this).parent().prevAll('.myGiid').html();
                    $.ajax({
                        type: 'post',
                        url: "<{:U('Admin/Goodsimg/delete')}>",
                        data: 'giid='+giid
                    });
                });
            </script>
</block>